﻿

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../Public/js/jquery-1.11.0.min.js" ></script>
<style>
	html,body{/*html for FF Moz NS7 OP */
	/*text-align:center; IE 5 IE 5.5*/
	margin:0;/* no margins body */
	padding:0;/* no padding body */
	height:100%;
	width:100%;
	background:transparent;
	font-size:13px;
	}
	
	input { border:1px solid #6dc1e1;width:202px;height:23px;}
	.error {height: 25px;line-height: 25px;margin-left:5px;}

</style>
<script type="text/javascript">
$(function(){
	$("#checkbox1").click(function(){
		 if($(this).is(':checked')){			
		$(".submit").attr('id','submit').css('cursor','pointer').children('img').attr('src','../Public/img/regBn.jpg');
		            }else{
		   $(".submit").attr('id','submit').css('cursor','text').children('img').attr('src','../Public/img/nregBn.jpg').attr('id','');
    }
});
function setContent(str) {
str = str.replace(/<\/?[^>]*>/g,''); //去除HTML tag
str.value = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
//str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
return str;
}

$('#submit').click(function(){

		nickname =setContent($("#nickname").val());
		psw = setContent($("#password").val());
		repsw = setContent($("#repassword").val());
		code = setContent($("#code").val());
		ifsubmit=true;
		if(nickname==""){
		$('#nick_error').text("*请输入昵称");
		ifsubmit = false;
		}else{
		$('#nick_error').text("");
		}
		
		if(psw==""){
		$('#ps_error').text("*请输入密码");
		ifsubmit = false;

		}else if(psw!=""){
			 if(psw.length<6){
			 $('#ps_error').text("*密码至少6位数");
			 ifsubmit = false;
			 }else{
				$('#ps_error').text("");
			 }	
		}
		
		if(repsw==""){
			$('#rps_error').text("*请确认密码");
			ifsubmit = false;
		}else if(repsw!=""){
			if(repsw!=psw){
				$("#rps_error").text("*两次密码不一致");	
				ifsubmit = false;
				}else{
				$("#rps_error").text("");
				}
		}
		if(code==""){
			$('#code_error').text("*验证码不能为空");
			ifsubmit = false;		
		}else{
		  $.ajax({
             type: "POST",
             url: "./codeverify.php",
			 data: {code:code},
			 dataType: "json",
             success: function(data){
				 if(!data){
				 ifsubmit = false;					 
				 $('#code_error').text("*验证码错误");				 
				 }else{
				 $('#code_error').text("");
				 if(ifsubmit){
					$('#myform').submit();
				}
				 }
									}
			})	
		
		}				
})

   })

</script>
</head>
<body style="background:#eff3f6;">

<div style="width:471px;">

<form  name="myform" id="myform"  action="./verify.php"  method="POST">

    <table width="400" style="margin:0 auto;">
      <tr >
        <td height="50" width="20%" style="vertical-align:middle;" ><div align="right"><a >昵称：</a></div></td>        
        <td width="50%"><input type="text" id="nickname" name="nickname" /></td>
		<td><span id="nick_error" class="error" style="color:red;font-size:12px;"></span></td>
    </tr>
     
     
      <tr>   <td height="50" style="vertical-align:middle;">   <div align="right"><a>密码：</a></div></td>
      
      <td ><input id="password" name="password" type="password" /></td>
	  <td><span class="error" id="ps_error" style="color:red;font-size:12px;"></span></td>
      
      
      <tr>
        <td height="50" style="vertical-align:middle;"><div align="right"><a >确认密码：</a></div></td>       
        <td><input  id="repassword" type="password" name="password" /></td>
		<td><span class="error" id="rps_error" style="color:red;font-size:12px;"></span></td>
     </tr>          
      <tr><td height="50" style="vertical-align:middle;">   <div align="right"><a>验证码：</a></div></td>
      
      <td ><input type="text" id="code" style="width:95px;" name="code"/><img  style="position:relative;left:4px;cursor:pointer;" title="点击刷新" src="./captcha.php" align="absbottom" onclick="this.src='./captcha.php?'+Math.random();" /></td>
	  <td><span class="error" id="code_error" style="color:red;font-size:12px;"></span> </td>
    </tr>

	
      <tr>
	  <td></td>      
	  <td height="45"><label><input type="checkbox" align="center" id="checkbox1" checked='' style="width:15px;height:auto;margin:0;padding:0;border:none;"/><span>我已阅读并同意<a href="#" style="text-decoration:none;color:#0084ff;">相关服务条款</a></span><label></td>   
	   <td></td>
	  </tr>	
	  <tr>
		<td></td>
		<td><div class="submit" id="submit" style="height:50px;width:150px;cursor:pointer;"><img src="../Public/img/regBn.jpg" /></div></td>
		 <td></td>
	  </tr>
    </table>

 </form>

</div>
 


</body>
</html>
